package com.example.widget.view

import android.os.Bundle
import androidx.compose.foundation.ScrollableColumn
import androidx.compose.foundation.ScrollableRow
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ContextAmbient
import androidx.compose.ui.platform.setContent
import androidx.compose.ui.unit.dp
import com.example.base.BaseActivity
import com.example.base.commonView.CommonCard
import com.example.base.commonView.CommonText
import com.example.base.commonView.CommonTheme
import com.example.base.commonView.TitleBar

/**
 * ScrollView，横向滑动和竖向滑动
 */
class ScrollViewActivity : BaseActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            showView()
        }
    }

    @Composable
    fun showView() {
        val context = ContextAmbient.current as ScrollViewActivity

        CommonTheme {
            Column(modifier = Modifier.fillMaxSize()) {
                TitleBar(title = "ScrollView") {
                    context.finish()
                }
                ScrollableRow {
                    for (i in 1..10) {
                        CommonCard {
                            CommonText(text = "item${i}")
                        }
                    }
                }

                ScrollableColumn {
                    for (i in 1..20) {
                        CommonCard {
                            CommonText(text = "item${i}", modifier = Modifier.padding(20.dp))
                        }
                    }
                }
            }
        }
    }
}